package for_test;

import for_test.IntComparator;
import for_test.SortMethod;

public class SortMethodBubble implements SortMethod{
	
	@Override
	
	public int[] sortArray(int[] array, IntComparator comparator) {
		for (int i=0; i<array.length-1; i++) {
			for (int j=i+1; j<array.length; j++ ) {
				if (isSwap(comparator, array[i], array[j])) {
					int temp = array[i];
					array[i] = array[j];
					array[j] = temp;
				}
			}
		}
		return array;
		
	}
	
	protected boolean isSwap(IntComparator comparator, int i, int j) {
		return comparator.compare(i, j) > 0;
	}
	


}
